//
//  MineWalletReleaseBankCardPopview.m
//  copyrightTrading
//
//  Created by edz on 2020/10/23.
//  Copyright © 2020 郭子一. All rights reserved.
//

#import "MineWalletReleaseBankCardPopview.h"

@implementation MineWalletReleaseBankCardPopview

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self setupUI];
    }
    return self;
}

- (void)setupUI
{
    self.frame = CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.height);
    [[UIApplication sharedApplication].keyWindow addSubview:self];
    
    UIView *bgView = [UIView new];
    bgView.backgroundColor = RGB_VALUE(0x000000);
    bgView.alpha = 0.4;
    [self addSubview:bgView];
    [bgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.offset(0);
    }];
    
    UIView *view = [[UIView alloc] init];
    view.backgroundColor = UIColor.whiteColor;
    view.layer.cornerRadius = 12;
    view.layer.masksToBounds = YES;
    [self addSubview:view];
    [view mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.offset(16);
        make.right.offset(-16);
        make.center.offset(0);
        make.height.mas_equalTo(221);
    }];
    
    UILabel *titleLabel = [UILabel new];
    titleLabel.text = @"确定解除该卡绑定 ？";
    titleLabel.font = JSS_MEDIUM_FONT(17);
    titleLabel.textAlignment = NSTextAlignmentCenter;
    [view addSubview:titleLabel];
    [titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.offset(86);
        make.centerX.offset(0);
        make.width.mas_equalTo(200);
        make.height.mas_equalTo(24);
    }];
    
    UIButton *closeBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [closeBtn setImage:[UIImage imageNamed:@"popViewClose"] forState:UIControlStateNormal];
    [closeBtn addTarget:self action:@selector(closeBtnClick) forControlEvents:UIControlEventTouchUpInside];
    [view addSubview:closeBtn];
    [closeBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.offset(-27);
        make.top.offset(24);
        make.width.height.mas_equalTo(24);
    }];
    
    UIButton *cancle = [UIButton buttonWithType:UIButtonTypeCustom];
    [cancle setTitle:@"取消" forState:UIControlStateNormal];
    [cancle setTitleColor:RGB_VALUE(0xFFFFFF) forState:UIControlStateNormal];
    [cancle.titleLabel setFont:JSS_MEDIUM_FONT_7];
    cancle.backgroundColor = RGB_VALUE(0x76A3F8);
    cancle.layer.masksToBounds = YES;
    cancle.layer.cornerRadius = 12;
    [cancle addTarget:self action:@selector(cancleBtnClick) forControlEvents:UIControlEventTouchUpInside];
    [view addSubview:cancle];
    [cancle mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.offset(-20);
        make.left.offset(21);
        make.height.mas_equalTo(51);
    }];
    
    UIButton *loginBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [loginBtn setTitle:@"确定" forState:UIControlStateNormal];
    [loginBtn setTitleColor:RGB_VALUE(0xFFFFFF) forState:UIControlStateNormal];
    [loginBtn.titleLabel setFont:JSS_MEDIUM_FONT_7];
    loginBtn.backgroundColor = RGB_VALUE(0xDC0000);
    loginBtn.layer.masksToBounds = YES;
    loginBtn.layer.cornerRadius = 12;
    [loginBtn addTarget:self action:@selector(loginBtnClick) forControlEvents:UIControlEventTouchUpInside];
    [view addSubview:loginBtn];
    [loginBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.offset(-20);
        make.right.offset(-21);
        make.left.equalTo(cancle.mas_right).offset(20);
        make.height.mas_equalTo(51);
        make.width.mas_equalTo(cancle.mas_width);
    }];
}

// 取消
- (void)cancleBtnClick
{
    [UIView animateWithDuration:0.1 animations:^{
        self.alpha = 0;
    } completion:^(BOOL finished) {
        [self removeFromSuperview];
    }];
}

// 确定
- (void)loginBtnClick
{
    if ([self.delegate respondsToSelector:@selector(releaseBankCardPopEnsureBtnClick)]) {
        [self.delegate releaseBankCardPopEnsureBtnClick];
    }
    [UIView animateWithDuration:0.1 animations:^{
        self.alpha = 0;
    } completion:^(BOOL finished) {
        [self removeFromSuperview];
    }];
}

- (void)closeBtnClick
{
    [UIView animateWithDuration:0.1 animations:^{
        self.alpha = 0;
    } completion:^(BOOL finished) {
        [self removeFromSuperview];
    }];
}

@end
